#!/bin/sh
#This shell deal with daily_ui stuff

cd ${BasePath}/A_dailybuild/emergent/xml

rm build_emergent_ui.xml ;
rm build_emergent_java.xml ;
rm build_emergent_class.xml ;

#if there is no more files in the folder , then we do not deal with the following process 
if test $(ls -a | wc -l) -gt 2
then 
		rm ../../../lis_sh/build_emergent_ui.xml ;
		echo "<project name=\"build_emergent_ui\" default=\"nothing\" basedir=\".\"> ">> ../../../lis_sh/build_emergent_ui.xml ; 
		echo "  <fileset dir=\"\${dev_server_base_path}\" casesensitive=\"no\"> ">> ../../../lis_sh/build_emergent_ui.xml ; 
		echo "  <patternset id=\"dev_server_base_emergent_ui\"> ">> ../../../lis_sh/build_emergent_ui.xml ; 
		awk ' BEGIN { RS="\<FileName FileType\=\"2\"\>" } ;{print $0} ' *.xml |  awk ' BEGIN { RS="\<\/FileName\>" } ; {print $0 } ' |awk '/[uU][iI]\\/ { print " \<include name\=\""$0"\" \/\>"} ' >> ../../../lis_sh/build_emergent_ui.xml ; 
		echo "  </patternset> ">> ../../../lis_sh/build_emergent_ui.xml ; 
		echo "	</fileset> ">> ../../../lis_sh/build_emergent_ui.xml ; 
		echo " </project>">> ../../../lis_sh/build_emergent_ui.xml ; 
		cd ${BasePath}
		cp lis_sh/build_emergent_ui.xml A_dailybuild/emergent/xml
		if test $(wc -l lis_sh/build_emergent_ui.xml | awk 'BEGIN { FS=" "} {print $1}') -gt 6
		then
				ant -k dailybuild_copy_update_ui_emergent
		fi
fi